---- _____  _____   _____ _____  __  __ ----
----|  __ \|  __ \ / ____|  __ \|  \/  |----
----| |__) | |__) | |  __| |  | | \  / |----
----|  _  /|  ___/| | |_ | |  | | |\/| |----
----| | \ \| |    | |__| | |__| | |  | |----
----|_|  \_\_|     \_____|_____/|_|  |_|----
--------------------------------------------
--Code relating to clientside interactions--
--------------------------------------------
AddCSLuaFile()

if SERVER then
	util.AddNetworkString( "GetEntityInteract" )
	util.AddNetworkString( "SetEntityInteract" )
	
	net.Receive("GetEntityInteract", function(len, ply) --Get the information we need to interact with the entity.
		local tbl = net.ReadTable()
		local ent = tbl[1]
		local activator = tbl[2]
		local interact = {}
		if(ent.Vendor)then
			interact[1] = ent
			interact[2].Interact = function()
				if(!menuOpen)then
					ShowPresetWindow()
				end
			end
		elseif(ent.QuestGiver)then
		
		elseif(ent.MatchMaker)then
		
		else
			ent:EmitSound("Sandbawgs/weapons/weapon_slowrocket/rocket_bounce.wav", 140, 100+math.random(-40,40))
		end
		net.Start("SetEntityInteract")
		net.WriteTable(interact)
		net.Send()
	end)
end

if CLIENT then
	net.Receive("SetEntityInteract", function(len, ply) --Set interaction of the entity clientside.
		tbl = net.ReadTable()
		tbl[2]:Interact()
	end)
end
